import com.example.c3p0.Util.C3p0Util;
import com.example.c3p0.javabean.User;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @auther 尚智江
 * @Date 2022/5/14 22:56
 */
public class QueryUser {
    public static void main(String[] args)throws SQLException {
        QueryRunner queryRunner = new QueryRunner(C3p0Util.getDataSource());
        String sql = "SELECT * FROM user";
        // 调用方法
        List<User> list = (List) queryRunner.query(sql,new BeanListHandler(User.class));
        for(User user : list){
            System.out.println("用户名："+user.getUsername()+"密码"+user.getPassword());
        }
    }
}
